/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "Insumos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Insumos.findAll", query = "SELECT i FROM Insumos i"),
    @NamedQuery(name = "Insumos.findByIdinsumo", query = "SELECT i FROM Insumos i WHERE i.idinsumo = :idinsumo"),
    @NamedQuery(name = "Insumos.findByNombre", query = "SELECT i FROM Insumos i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Insumos.findByTipomedida", query = "SELECT i FROM Insumos i WHERE i.tipomedida = :tipomedida"),
    @NamedQuery(name = "Insumos.findByCantidadstock", query = "SELECT i FROM Insumos i WHERE i.cantidadstock = :cantidadstock")})
public class Insumos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDINSUMO")
    private Integer idinsumo;
    @Size(max = 45)
    @Column(name = "NOMBRE")
    private String nombre;
    @Size(max = 45)
    @Column(name = "TIPOMEDIDA")
    private String tipomedida;
    @Size(max = 45)
    @Column(name = "CANTIDADSTOCK")
    private String cantidadstock;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idinsumo")
    private Collection<RecetasInsumos> recetasInsumosCollection;

    public Insumos() {
    }

    public Insumos(Integer idinsumo) {
        this.idinsumo = idinsumo;
    }

    public Integer getIdinsumo() {
        return idinsumo;
    }

    public void setIdinsumo(Integer idinsumo) {
        this.idinsumo = idinsumo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getTipomedida() {
        return tipomedida;
    }

    public void setTipomedida(String tipomedida) {
        this.tipomedida = tipomedida;
    }

    public String getCantidadstock() {
        return cantidadstock;
    }

    public void setCantidadstock(String cantidadstock) {
        this.cantidadstock = cantidadstock;
    }

    @XmlTransient
    public Collection<RecetasInsumos> getRecetasInsumosCollection() {
        return recetasInsumosCollection;
    }

    public void setRecetasInsumosCollection(Collection<RecetasInsumos> recetasInsumosCollection) {
        this.recetasInsumosCollection = recetasInsumosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idinsumo != null ? idinsumo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Insumos)) {
            return false;
        }
        Insumos other = (Insumos) object;
        if ((this.idinsumo == null && other.idinsumo != null) || (this.idinsumo != null && !this.idinsumo.equals(other.idinsumo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Insumos[ idinsumo=" + idinsumo + " ]";
    }
    
}
